using System;
using System.Reflection;
using GameServer.ShootingGame.WeaponsClasses;

namespace GameServer.ShootingGame.RenderableClasses
{

    public class PickupObject : GameObject
    {
        /// <summary>
        /// The item received when this object is picked up.
        /// </summary>
        public GameObject pickupItem;
        public PickupObject()
        {
            width = 10;
            height = 10;
        }

        /// <summary>
        /// Returns the item associated with this pickup object and calls StopUpdate.
        /// </summary>
        /// <returns></returns>
        public GameObject PickedUp() {
            
            //ConstructorInfo ci = type.GetConstructors()[0];
            //return ci.Invoke(new Object[0]) as Weapon;
            //return (Activator.CreateInstanceFrom(Assembly.GetExecutingAssembly().FullName, type.ToString())).Unwrap() as Weapon;
            StopUpdate();
            return pickupItem;
		}

        /// <summary>
        /// Adds the object to the update list. Returns false if the object is already on the list.
        /// </summary>
        override public bool AddObject()
        {
            if (!GamePlayManager.PickupList.Contains(this))
            {
                GamePlayManager.PickupList.Add(this);
                return true;
            }
            return false;
        }

        /// <summary>
        /// Removes the object from the update list. Returns false if the object was not on the update list.
        /// </summary>
        /// <returns></returns>
        override public bool RemoveObject()
        {
            if (GamePlayManager.PickupList.Contains(this))
            {
                GamePlayManager.PickupList.Remove(this);
                return true;
            }
            return false;
        }

        public override GamePlayManager GamePlayManager
        {
            get
            {
                return base.GamePlayManager;
            }
            set
            {
                base.GamePlayManager = value;
                id = GamePlayManager.nextOrdinanceItemID++;
            }
        }
    }
}
